package com.healthcloud.controller;


import com.healthcloud.entity.BaseCodeEntity;
import com.healthcloud.entity.Hospital;
import com.healthcloud.service.BaseService;
import com.healthcloud.service.HospitalService;
import com.healthcloud.utils.ApiRes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@ApiIgnore
@Controller
@RequestMapping(value = "/base")
public class BaseController {
	
	@Autowired
    private BaseService baseService;

    @Autowired
    private HospitalService hospitalService;

	@RequestMapping(value = "/getBaseCode")
    @ResponseBody
    public ApiRes getBaseCode(BaseCodeEntity bean, Model model){
        List<BaseCodeEntity> list = baseService.getBaseCode(bean);
        return  new ApiRes(true,list,null,null);

    }

    @RequestMapping(value = "/selectHosp")
    public @ResponseBody
    ApiRes selectHosp(String limit, String offset, String name){
        List<Hospital> list = hospitalService.searchByName(name, offset, limit);
        Integer total = hospitalService.countByName(name, offset, limit);
        return new ApiRes(true,list,null,String.valueOf(total));
    }

}
